package HomeWork;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class DataUtilTwo {
    private DataUtilTwo() {}
    //创表
    private static void  util(){
        Connection connection=null;
        Statement statement=null;
        ResultSet resultSet=null;
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            connection= DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/j180?useSSL=false&serverTimezone=Asia/Shanghai","root","994152993");
            //System.out.println(connection);
            statement=connection.createStatement();
            String sql="create table student(\n" +
                    "\t_id int primary key auto_increment,\n" +
                    "\t_name varchar(50),\n" +
                    "\t_age int,\n" +
                    "\t_code varchar(50),\n" +
                    "\t_sex char(2),\n" +
                    "\t_fk int \n" +
                    ");\n\n" +
                    "INSERT INTO t_student(_name,_age,_code,_sex,_fk) VALUES \n" +
                    "('凤姐',22,'网络','女',1),\n" +
                    "('屌丝哥',27,'网络','男',1),\n" +
                    "('马化腾',32,'IT','男',2),\n" +
                    "('李咏',32,'央视','男',3),\n" +
                    "('张朝阳',35,'IT','男',1),\n" +
                    "('倪萍',32,'央视','女',3),\n" +
                    "('白岩松',32,'央视','男',2),\n" +
                    "('崔永元',37,'央视','男',3),\n" +
                    "('朱军',41,'央视','男',3),\n" +
                    "('柳传志',42,'IT','男',2),\n" +
                    "('雷军',32,'IT','男',2),\n" +
                    "('乔布斯',52,'IT','男',2),\n" +
                    "('唐骏',38,'IT','',1),\n" +
                    "('刘强东',35,'IT','男',1),\n" +
                    "('周鸿祎',36,'网络','男',1)";
            int num=statement.executeUpdate(sql);
            System.out.println(num);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
